<?php

/**
 * Class Model
 * @package think
 * @method Query table(string $table) static 指定数据表（含前缀）
 * @method Query name(string $name) static 指定数据表（不含前缀）
 * @method Query where(mixed $field, string $op = null, mixed $condition = null) static 查询条件
 * @method Query join(mixed $join, mixed $condition = null, string $type = 'INNER') static JOIN查询
 * @method mixed find(mixed $data = null) static 查询单个记录
 * @method mixed select(mixed $data = null) static 查询多个记录
 * @method integer insert(array $data, boolean $replace = false, boolean $getLastInsID = false, string $sequence = null) static 插入一条记录
 */
abstract class Model
{

    /**
     * 查询类名
     * @var string
     */
    protected static $name;

    public static function __callStatic($method, $args)
    {
        if (empty(self::$name)) {
            $name = str_replace('\\', '/', static::class);
            self::$name = parse_name(basename($name));
        }
        return call_user_func_array([new Mysql(self::$name), $method], $args);
    }
}
